package com.educhains.module.activity.service.impl;

import com.educhains.module.activity.persist.dao.ActivityDAO;
import com.educhains.module.activity.service.ActivityService;
import com.educhains.module.activity.vo.mb_model.Activity;
import com.educhains.module.activity.vo.mb_model.ActivityJoin;
import com.educhains.module.demo.vo.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {

    @Autowired
    private ActivityDAO activityDAO;


    public int insertSelective(Activity record) {
        return activityDAO.insertSelective(record);
    }

    public Activity selectByPrimaryKey(String activityId) {
        return activityDAO.selectByPrimaryKey(activityId);
    }


    public List<Activity> selectActivityList() {

        return activityDAO.selectActivityList();
    }

    public Page showActivityPage(int pageNum) {

        int totalRecord = activityDAO.selectActivityList().size();
        Page page = new Page(pageNum, totalRecord);
        List list = activityDAO.showByPage(page.getStartIndex(), page.getPageSize());
        page.setList(list);
        return page;
    }

    public List<Activity> getActivityListByUserIdWithLimit(String userId, int limit) {

        return activityDAO.getActivityListByUserIdWithLimit(userId, limit);
    }

    public List<Activity> selectActivityListLimit(@Param("activityNum") int activityNum, @Param("type") String type) {
        return activityDAO.selectActivityListLimit(activityNum, type);
    }

    public List<ActivityJoin> selecetActivityJoinListLimitByAID(String activityId, int num) {
        return activityDAO.selecetActivityJoinListLimitByAID(activityId, num);
    }

    public List<ActivityJoin> selecetActivityJoinListLimitByUID(String userId, int num) {
        return activityDAO.selecetActivityJoinListLimitByUID(userId, num);
    }

    public int insertActivityJoin(ActivityJoin record) {
        return activityDAO.insertActivityJoin(record);
    }
}
